import { StoreOptions } from "vuex";

export default {
  namespaced: true,
  state: () => ({
    loginUser: {
      userName: "未登录",
      role: "notAdmin",
    },
  }),
  actions: {
    // async getLoginUser({ commit, state }, payload) {
    //   // 从远程请求获取登录信息
    //   const res = await UserControllerService.getLoginUserUsingGet();
    //   if (res.code === 0) {
    //     commit("updateUser", res.data);
    //   } else {
    //     commit("updateUser", {
    //       ...state.loginUser,
    //       userRole: ACCESS_ENUM.NOT_LOGIN,
    //     });
    //   }
    // },
    getLoginUser({ commit }) {
      commit("updateUser", { userName: "gky" });
    },
  },
  mutations: {
    updateUser(state, payload) {
      state.loginUser = payload;
    },
  },
} as StoreOptions<any>;
